POV-Ray : Newsgroups : povray.newusers : isosurfaces problem (hello Mike) : isosurfaces problem (hello Mike) Server Time
29 Jul 2024 20:23:24 EDT (-0400)
  isosurfaces problem (hello Mike)  
From: Mike Williams
Date: 26 Feb 2005 08:12:05
Message: <WASm$FAUWHICFwAT@econym.demon.co.uk>
Wasn't it kurtz le pirate who wrote:
>hello,
>
>i want to model cable with 2 parts : cylindrical and part of torus.
>
>for cylindrical, i have no problem. code i use is :
>
>#declare p1 = 8;    // number of helixes 
>#declare p2 = 0.25; // number of turns per unit length 
>#declare p3 = 1.75; // minor radius
>#declare p4 = 1.50; // major radius
>#declare p5 = 1.00; // shape parameter
>#declare p6 = 1;    // cross section type -> circle
>#declare p7 = 0;    // cross section rotation angle
>
>#declare containerSize = 3.20;
>#declare maxGradiantValue = 10;
>
>#declare cableFunction = function { f_helix1(x, y, z, p1, p2, p3, p4, 
>p5, p6, p7) }
>
>#declare cableCyl = isosurface {
>  function { cableFunction(x,y,z) }
>  contained_by { 
>    box { <+containerSize, 0.00, +containerSize> <-containerSize, 
>-cableLen, -containerSize>   }
>    }
>  max_gradient maxGradiantValue
>  }
>
>
>for "torus part", i do this code :
>
>#declare cableTorus = isosurface {
>  function { cableFunction(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
>  contained_by { 
>    sphere { 0,*MajorRadius1.2 }
>    }
>  max_gradient maxGradiantValue
>  rotate 90*x 
>  }
>with MajorRadius = 80.00
>
>
>... but all the thing a get is a plain torus !!!
>
>anyone can help me ?
>thanks


The easy problem: If you're trying to follow my example code from 
<http://www.econym.demon.co.uk/isotut/substitute.htm#polar>
you'll need to flip the axes like I do. 

Try declaring a second cableFunction with flipped axes like this:

#declare cableFunction2 = function { f_helix1(x, z, y, p1, p2, p3,
p4,p5, p6, p7) }

#declare cableTorus = isosurface {
  function { cableFunction2(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
  contained_by { 
    sphere { 0,MajorRadius*1.2 }
    }
  max_gradient 1.3
  rotate 90*x 
  }

The problem you'll then notice is that p2 only relates to the number of
turns per unit length before the substitution, so you only get something
like pi*p2 turns around the whole loop, and that's nowhere near enough.

You might think that would be easy to solve by increasing the value of
p2, but unfortunately you hit the problem that f_helix1 only behaves
predictably when the major radius is larger than the minor radius. If
you increase p2, things go horribly wrong.

So, I think you've got to use f_helix2, like this:

#declare cableFunction2 = function { f_helix2(x, z, y, 0,
p2*MajorRadius, p3, p4,p5, p6, p7) }

#declare cableTorus = isosurface {
  function { cableFunction2(f_r(x,y,z)-MajorRadius, y, f_th(x,y,z)) }
  contained_by { 
    sphere { 0,MajorRadius*1.2 }
    }
  max_gradient 1.3
  rotate 90*x 
  }

However, f_helix2 doesn't support multi-stranding, so if you want an
eight strand cable you'll need eight copies of that isosurface. That's
not quite as bad as it seems because the low value of max_gradient means
that it renders pretty quickly.

#declare Angle = 360/p2/MajorRadius/8;

#declare N=0;
#while (N<8)
  object {cableTorus pigment {rgb 1} rotate z*Angle*N}
  #declare N=N+1;
#end

This then leaves you with the final problem that this cable doesn't look
quite the same as the cylindrical one. That's because it's still using
f_helix1. So you'll need to do the same thing with that if you want them
to match.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.